package com.eling.elcms.travel.service.impl;

import com.eling.elcms.basedoc.model.PersonalInfo;
import com.eling.elcms.basedoc.service.IPersonalInfoManager;
import com.eling.elcms.core.AppContext;
import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.exception.BusinessException;
import com.eling.elcms.core.service.impl.GenericManagerImpl;
import com.eling.elcms.core.util.PropertyUtils;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.ordermanager.model.ServicePoint;
import com.eling.elcms.ordermanager.service.IServicePointManager;
import com.eling.elcms.privilege.service.IRbacService;
import com.eling.elcms.system.model.CommonUser;
import com.eling.elcms.travel.dao.ISignUpChargeDao;
import com.eling.elcms.travel.dao.ISignUpRegisterDao;
import com.eling.elcms.travel.model.*;
import com.eling.elcms.travel.model.PlanItemGroup.CheckInStatus;
import com.eling.elcms.travel.model.PlanItemGroup.SignUpStatus;
import com.eling.elcms.travel.model.view.SignUpChargeStatusView;
import com.eling.elcms.travel.model.view.SignUpChargeView;
import com.eling.elcms.travel.model.view.SignUpRegisterSaveView;
import com.eling.elcms.travel.model.view.SignUpRegisterView;
import com.eling.elcms.travel.model.view.SignUpRegisterView.PayFul;
import com.eling.elcms.travel.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

@Service
public class SignUpRegisterManagerImpl extends GenericManagerImpl<SignUpRegister, Long>
		implements ISignUpRegisterManager {
	ISignUpRegisterDao signUpRegisterDao;
	@Autowired
	IRbacService rbacService;
	@Autowired
	IRoomPersonalInfoManager roomPersonalInfoManager;
	@Autowired
	private ISignUpChargeManager signUpChargeManager;
	@Autowired
	private ISignUpRefundManager signUpRefundManager;
	@Autowired
	ICustomerManager customerManager;
	@Autowired
	private IServicePointManager servicepointmanager;
	@Autowired
	private IPlanItemManager itemManager;
	@Autowired
	private IPlanItemGroupManager planItemGroupManager;
	@Autowired
	private IPersonalInfoManager personalInfoManager;
	@Autowired
	private ITravelContractManager travelContractManager;
	@Autowired
	private INonMemberGroupManager nonMemberGroupManager;
	@Autowired
	private INonMemberRegisterManager nonMemRegisterManager;
	@Autowired
	private ISignUpChargeDao signUpChargeDao;
	@Autowired
	private IGroupReserveManager groupReserveManager;

	@Autowired
	public void setItemDao(ISignUpRegisterDao signUpRegisterDao) {
		this.dao = signUpRegisterDao;
		this.signUpRegisterDao = signUpRegisterDao;
	}

	@Override
	public List<SignUpRegisterView> queryAll(SignUpRegister signUp, String payFul) {
		Date endDate = PropertyUtils.getProperty(signUp, "planItemGroup.planItem.startDateEnd");
		// 查询当前日期下所有已发布的团和计划信息
		List<SignUpRegisterView> list = signUpRegisterDao.queryMember(
				signUp.getPlanItemGroup().getPlanItem().getDestination(),
				signUp.getPlanItemGroup().getPlanItem().getStartDate(), endDate);
		// 取出所有的团
		List<Long> pkPlanItem = new ArrayList<Long>();
		for (SignUpRegisterView view : list) {
			pkPlanItem.add(view.getPkPlanItem());
		}
		// 按团和服务点去查询团与服务点的关系
		PlanItemGroup pg = new PlanItemGroup();
		PropertyUtils.setProperty(pg, "planItem.pkPlanItemIn", pkPlanItem);
		PropertyUtils.setProperty(pg, "servicePoint.pkServicePoint",
				signUp.getPlanItemGroup().getServicePoint().getPkServicePoint());
		List<PlanItemGroup> planItemGroupList = planItemGroupManager.query(pg);

		// 遍历2个集合把对应的报名人数和状态带进去
		List<Long> pkList = new ArrayList<>();
		
		for (int i = 0; i < list.size(); i++) {
			for (PlanItemGroup plan : planItemGroupList) {
				Boolean flag = true;
				for (AdjustType at : plan.getAdjustTypes()) {
					if (at.name().equals(AdjustType.Abolished.name())) {
						flag = false;
						break;
					}
				}
				if (flag) {
					int j = 0;
					// 去掉退团人员
					for (SignUpRegister signUpRegister : plan.getSignUps()) {
						if (signUpRegister.getExitGroup() == null || signUpRegister.getExitGroup() != true) {
							j++;
						}
					}
					if (list.get(i).getPkPlanItem().equals(plan.getPlanItem().getPkPlanItem())) {
						List<SignUpRegister> signList = new ArrayList<SignUpRegister>(plan.getSignUps());
						List<SignUpRegister> reList = new ArrayList<>();
						for (SignUpRegister signUpRegister : signList) {
							if (signUpRegister.getExitGroup() == null || signUpRegister.getExitGroup() != true) {
								reList.add(signUpRegister);
							}
						}
						list.get(i).setSignUpRegister(reList);
						list.get(i).setCountMember(j);
						if (plan.getSignUpStatus() != null) {
							list.get(i).setSignUpStatus(PlanItemGroup.SignUpStatus.Confirm);
						}
						break;
					}
				} else {
					pkList.add(plan.getPlanItem().getPkPlanItem());
					//list.remove(i);
					//i--;
				}
			}
		}
		
		for(int i = 0; i < list.size();i++){
			if(pkList.contains(list.get(i).getPkPlanItem())){
				list.remove(i);
			}
		}
			
		List<SignUpChargeView> queryPlanItemByPk = new ArrayList<>();
		for (Long pk : pkPlanItem) {
			List<SignUpChargeView> planItemByPk = signUpChargeDao
					.queryPlanItemByPk(signUp.getPlanItemGroup().getServicePoint().getPkServicePoint(), pk);
			queryPlanItemByPk.addAll(planItemByPk);
		}
		List<Long> chargeList = new ArrayList<Long>();
		List<Long> chargeCompleteList = new ArrayList<Long>();
		List<Long> reviewList = new ArrayList<Long>();
		List<Long> adjustmentList = new ArrayList<Long>();
		List<Long> adjustmentReviewList = new ArrayList<Long>();

		for (SignUpChargeView signUpChargeView : queryPlanItemByPk) {
			if ((Integer.parseInt(signUpChargeView.getSignUpNumber()) > Integer
					.parseInt(signUpChargeView.getChargeNumber()) && signUpChargeView.getIsAdjustment() == false)||
					(Integer.parseInt(signUpChargeView.getSignUpNumber())==0)) {
				chargeList.add(signUpChargeView.getPkPlanItem());
			}
			else if (Integer.parseInt(signUpChargeView.getSignUpNumber()) == Integer
					.parseInt(signUpChargeView.getChargeNumber())
					&& SignUpStatus.Confirm.toString().equals(signUpChargeView.getStatus())) {
				chargeCompleteList.add(signUpChargeView.getPkPlanItem());
			}
			else if (signUpChargeView.getIsAdjustment() == false
					&& !SignUpStatus.Confirm.toString().equals(signUpChargeView.getStatus())) {
				
				reviewList.add(signUpChargeView.getPkPlanItem());
			}
			else if (signUpChargeView.getIsAdjustment() == true
					&& Integer.parseInt(signUpChargeView.getSignUpNumber()) > Integer
							.parseInt(signUpChargeView.getChargeNumber())) {
				adjustmentList.add(signUpChargeView.getPkPlanItem());
			}
			else if (SignUpStatus.AdjustmentReview.toString().equals(signUpChargeView.getStatus())) {
				adjustmentReviewList.add(signUpChargeView.getPkPlanItem());
			}
		}

		List<SignUpRegisterView> returnList = new ArrayList<>();

		if ("Charge".equals(payFul)) {
			for (int i = 0; i < list.size(); i++) {
				SignUpRegisterView signUpRegisterView = list.get(i);
				if(signUpRegisterView!=null){
					if(signUpRegisterView.getSignUpRegister()==null){
						signUpRegisterView.setPayFul(PayFul.Charge);
						returnList.add(signUpRegisterView);
					}
					if (chargeList.contains(signUpRegisterView.getPkPlanItem())) {
						signUpRegisterView.setPayFul(PayFul.Charge);
						returnList.add(signUpRegisterView);
					}
				}
			}
			return returnList;
		} else if ("ChargeComplete".equals(payFul)) {
			for (int i = 0; i < list.size(); i++) {
				SignUpRegisterView signUpRegisterView = list.get(i);
				if (chargeCompleteList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.ChargeComplete);
					returnList.add(signUpRegisterView);
				}
			}
			return returnList;
		} else if ("Review".equals(payFul)) {
			for (int i = 0; i < list.size(); i++) {
				SignUpRegisterView signUpRegisterView = list.get(i);
				if (reviewList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.Review);
					returnList.add(signUpRegisterView);
				}
			}
			return returnList;
		} else if ("Adjustment".equals(payFul)) {
			for (int i = 0; i < list.size(); i++) {
				SignUpRegisterView signUpRegisterView = list.get(i);
				if (adjustmentList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.Adjustment);
					returnList.add(signUpRegisterView);
				}
			}
			return returnList;
		} else if ("AdjustmentReview".equals(payFul)) {
			for (int i = 0; i < list.size(); i++) {
				SignUpRegisterView signUpRegisterView = list.get(i);
				if (adjustmentReviewList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.AdjustmentReview);
					returnList.add(signUpRegisterView);
				}
			}
			return returnList;
		} else {
			for (int i = 0; i < list.size(); i++) {
				SignUpRegisterView signUpRegisterView = list.get(i);
				if (chargeList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.Charge);
					returnList.add(signUpRegisterView);
				} else if (chargeCompleteList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.ChargeComplete);
					returnList.add(signUpRegisterView);
				} else if (reviewList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.Review);
					returnList.add(signUpRegisterView);
				} else if (adjustmentList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.Adjustment);
					returnList.add(signUpRegisterView);
				} else if (adjustmentReviewList.contains(signUpRegisterView.getPkPlanItem())) {
					signUpRegisterView.setPayFul(PayFul.AdjustmentReview);
					returnList.add(signUpRegisterView);
				} else {
					signUpRegisterView.setPayFul(PayFul.Charge);
					returnList.add(signUpRegisterView);
				}
			}
			return returnList;
		}
	}

	@Override
	public List<TravelContract> querycertificates(SearchCondition sc, SignUpRegister signUp, Long pkServicePoint) {
		return signUpRegisterDao.querycertificates(sc.getS(), signUp, pkServicePoint);
	}

	@Override
	public List<SignUpRegister> saveAll(SignUpRegisterSaveView signUp) {
		ServicePoint sp = servicepointmanager.get(signUp.getPkServicePoint());
		PlanItem pi = itemManager.get(signUp.getPkPlanItem());
		List<SignUpRegister> list = signUp.getSignUpRegister();
		List<SignUpRegister> returnlist = new ArrayList<SignUpRegister>();

		// 建立计划和团的关系
		PlanItemGroup pg = new PlanItemGroup();
		pg.setPlanItem(pi);
		pg.setServicePoint(sp);
		List<PlanItemGroup> lists = planItemGroupManager.query(pg);
		if (lists.size() > 0) {
			pg = lists.get(0);
		} else {
			pg.setAlliance(false);
			pg.setCheckInStatus(CheckInStatus.Initial);
			pg.setVersion(0);
			pg.setIsAdjustment(false);
			pg = planItemGroupManager.save(pg);// 旅游团和联盟、服务点关系
		}

		// 保存报名信息
		List<Long> pklist = new ArrayList<Long>();
		for (SignUpRegister sr : list) {
			// 建立合同签约临时表
			pklist.add(sr.getTravelContract().getPkTravelContract());
			// 保存人员报名信息，非会员需要推送客户信息
			if (sr.getMember() == true) {
				sr.setPersonalInfo(sr.getPersonalInfo());
				sr.setPlanItemGroup(pg);
				returnlist.add(sr);
			} else {
				CommonUser cu = (CommonUser) AppContext.curUser();
				Customer cus = new Customer();
				cus.setOrganization(cu.getOrganization());
				PersonalInfo personalInfo = sr.getPersonalInfo();
				if(personalInfo.getIdNumber()!=null){
					if(personalInfo.getIdNumber() == ""){
						personalInfo.setIdNumber(null);
					}else{
						PersonalInfo pInfo = roomPersonalInfoManager.queryById(personalInfo.getIdNumber());
						if(pInfo == null){
							personalInfo.setVersion(0);
							personalInfo = personalInfoManager.save(personalInfo);
						}else {
							if(personalInfo.getName()!=null){
								pInfo.setName(personalInfo.getName());
							}
							if(personalInfo.getSex()!=null){
								pInfo.setSex(personalInfo.getSex());
							}	
							if(personalInfo.getMobilePhone()!=null){
								pInfo.setMobilePhone(personalInfo.getMobilePhone());
							}	
							if(personalInfo.getBirthday()!=null){
								pInfo.setBirthday(personalInfo.getBirthday());
							}	
							if(personalInfo.getElectronicMail()!=null){
								pInfo.setElectronicMail(personalInfo.getElectronicMail());
							}	
							if(personalInfo.getHouseRegister()!=null){
								pInfo.setHouseRegister(personalInfo.getHouseRegister());
							}	
							if(personalInfo.getAddress()!=null){
								pInfo.setAddress(personalInfo.getAddress());
							}	
							if(personalInfo.getPhone()!=null){
								pInfo.setAddress(personalInfo.getPhone());
							}
							personalInfo = personalInfoManager.save(pInfo);
						}
					}
				}else {
					personalInfo = personalInfoManager.save(personalInfo);
				}
				PersonalInfo pis = personalInfoManager.save(personalInfo);
				cus.setPersonalInfo(pis);
				cus.setProductType(sr.getTravelContract().getProductType());
				cus.setDataSource(Customer.DataSource.SignUp);
				cus.setSaleConsultant(cu);
				cus = customerManager.save(cus);
				sr.setPersonalInfo(pis);
				sr.setPlanItemGroup(pg);
				returnlist.add(sr);
			}
		}

		// 关联报名信息和合同签约
		TravelContract tc = new TravelContract();
		PropertyUtils.setProperty(tc, "pkTravelContractIn", pklist);
		List<TravelContract> tclist = travelContractManager.query(tc);
		SignUpRegister sr = returnlist.get(0);
		PersonalInfo p = personalInfoManager.get(sr.getPersonalInfo().getPkPersonalInfo());
		sr.setPersonalInfo(p);
		for (TravelContract tcs : tclist) {
			if (tcs.getPkTravelContract().equals(sr.getTravelContract().getPkTravelContract())) {
				sr.setTravelContract(tcs);
			}
		}

		// 将报名信息保存到团信息中
		returnlist = super.save(returnlist);
		SignUpRegister ss = new SignUpRegister();
		ss.setPlanItemGroup(pg);
		List<SignUpRegister> signup = super.query(ss);
		signup.add(returnlist.get(0));
		pg.setSignUps(new HashSet<SignUpRegister>(signup));
		planItemGroupManager.save(pg);

		return returnlist;
	}

	@Override
	public Long getCheckInDays(SignUpRegister signUp) {
		Long days = 0L;
		if (signUp.getCheckInDate() != null && signUp.getCheckOutDate() != null) {
			days = (signUp.getCheckOutDate().getTime() - signUp.getCheckInDate().getTime()) / (24 * 60 * 60 * 1000);
		}

		return days;
	}

	@Override
	public Msg deleteNonMemberGroup(Long pkSignUpRegister) {
		NonMemberRegister non = new NonMemberRegister();
		PropertyUtils.setProperty(non, "signUpRegister.pkSignUpRegister", pkSignUpRegister);
		// 查询该报名是否包含中间表
		List<NonMemberRegister> list = nonMemRegisterManager.query(non);
		if (!list.isEmpty()) {
			nonMemRegisterManager.remove(list);
		} else {
			remove(pkSignUpRegister);
		}
		return new Msg("删除成功");
	}

	@Override
	public SignUpRegister saveCustomer(SignUpRegister signUp, Date checkInDate, Date checkOutDate,
			Long pkPersonalInfo) {
		if (checkInDate != null && checkOutDate != null) {
			PersonalInfo p = new PersonalInfo();
			p.setName(signUp.getPersonalInfo().getName());
			p.setIdNumber(signUp.getPersonalInfo().getIdNumber());
			p.setMobilePhone(signUp.getPersonalInfo().getMobilePhone());
			SignUpRegister sign = new SignUpRegister();
			sign.setPersonalInfo(p);
			sign.setCheckInDate(checkInDate);
			sign.setCheckOutDate(checkOutDate);
			PropertyUtils.setProperty(sign, "validatePrivilege", false);
			List<SignUpRegister> list = signUpRegisterDao.query(sign);
			if (!list.isEmpty()) {
				throw new BusinessException("该用户已经登记过了！");
			}
		}
		if (signUp.getCustomer()) {
			PersonalInfo pp = personalInfoManager.get(pkPersonalInfo);
			signUp.setPersonalInfo(pp);
			signUp = save(signUp);
		} else {
			PersonalInfo personalInfo = signUp.getPersonalInfo();
			if(personalInfo.getIdNumber()!=null){
				if(personalInfo.getIdNumber() == ""){
					personalInfo.setIdNumber(null);
				}else{
					PersonalInfo pInfo = roomPersonalInfoManager.queryById(personalInfo.getIdNumber());
					if(pInfo == null){
						personalInfo = personalInfoManager.save(personalInfo);
					}else {
						if(personalInfo.getName()!=null){
							pInfo.setName(personalInfo.getName());
						}
						if(personalInfo.getSex()!=null){
							pInfo.setSex(personalInfo.getSex());
						}	
						if(personalInfo.getMobilePhone()!=null){
							pInfo.setMobilePhone(personalInfo.getMobilePhone());
						}	
						if(personalInfo.getBirthday()!=null){
							pInfo.setBirthday(personalInfo.getBirthday());
						}	
						if(personalInfo.getElectronicMail()!=null){
							pInfo.setElectronicMail(personalInfo.getElectronicMail());
						}	
						if(personalInfo.getHouseRegister()!=null){
							pInfo.setHouseRegister(personalInfo.getHouseRegister());
						}	
						if(personalInfo.getAddress()!=null){
							pInfo.setAddress(personalInfo.getAddress());
						}	
						personalInfo = personalInfoManager.save(pInfo);
					}
				}
				signUp.setPersonalInfo(personalInfo);
			}
			signUp = save(signUp);
			Customer cu = new Customer();
			cu.setPersonalInfo(signUp.getPersonalInfo());
			cu.setStatus(Customer.Status.NoIntention);
			cu.setDataSource(Customer.DataSource.NoMember);
			cu.setOrganization(((CommonUser) AppContext.curUser()).getOrganization());
			cu.setSaleConsultant((CommonUser) AppContext.curUser());
			cu.setTransMember(false);
			cu.setVersion(0);
			cu = customerManager.save(cu);
		}
		return signUp;
	}

	@Override
	public List<SignUpChargeStatusView> queryChargeStatus(Long pkPlanItemGroup) {
		List<SignUpChargeStatusView> returnList = new ArrayList<>();
		PlanItemGroup planItemGroup = planItemGroupManager.get(pkPlanItemGroup);
		GroupReserve groupReserve=new GroupReserve();
		groupReserve.setPlanItemGroup(planItemGroup);
		List<GroupReserve> groupReserveList=groupReserveManager.query(groupReserve);
		SignUpRegister signUpRegister = new SignUpRegister();
		signUpRegister.setPlanItemGroup(planItemGroup);
		// 查询所有登记
		List<SignUpRegister> signUpList = signUpRegisterDao.query(signUpRegister);
		if (!signUpList.isEmpty()) {
			List<Long> pkSUList = signUpList.stream().map(a -> a.getPkSignUpRegister()).collect(Collectors.toList());
			SignUpCharge signUpCharge = new SignUpCharge();
			PropertyUtils.setProperty(signUpCharge, "signUpRegister.pkSignUpRegisterIn", pkSUList);
			// 查询所有收费
			List<SignUpCharge> sucList = signUpChargeManager.query(signUpCharge);
			// 所以退费
			List<SignUpRefund> suRefundList = new ArrayList<>();
			if(!sucList.isEmpty()){
				List<Long> pkSUCList = sucList.stream().map(a->a.getPkSignUpCharge()).collect(Collectors.toList());
				SignUpRefund signUpRefund = new SignUpRefund();
				PropertyUtils.setProperty(signUpRefund, "signUpCharge.pkSignUpChargeIn", pkSUCList);
				suRefundList = signUpRefundManager.query(signUpRefund);
			}
			for (SignUpRegister sur : signUpList) {
				SignUpChargeStatusView view = new SignUpChargeStatusView();
				Boolean charge = false,refund = false;
				for (SignUpCharge suc : sucList) {
					// 报名存在收费数据且实收不为空时证明该报名已收费
					if (suc.getSignUpRegister().getPkSignUpRegister().equals(sur.getPkSignUpRegister())
							&& suc.getPayable() != null) {
						charge = true;
						break;
					}
				}
				for(SignUpRefund suRefund : suRefundList){
					// 报名存在退费数据且实退不为空是证明该报名已退团退费
					if(suRefund.getSignUpCharge().getSignUpRegister().getPkSignUpRegister().equals(sur.getPkSignUpRegister())
							&& suRefund.getRefund() != null){
						refund = true;
						break;
					}
				}
				view.setSignUpRegister(sur);
				if (!charge) {
					view.setCharge(false);
				} else {
					view.setCharge(true);
				}
				if(refund){
					view.setRefund(true);
				}else{
					view.setRefund(false);
				}
				returnList.add(view);
			}
		}
		if(returnList.size()>0){
			returnList.get(0).setGroupReserve(groupReserveList.size()>0?groupReserveList.get(0):null);
		}
		return returnList;
	}

	@Override
	public Map<String, Object> adjustAddSignUp(Long pkGroup, String dataSource, SignUpRegister signUp) {
		Map<String, Object> map = new HashMap<>();
		if (dataSource.equals(CheckInImplement.DataSource.NonMember.name())) {
			NonMemberGroup nonMemberGroup = nonMemberGroupManager.get(pkGroup);
			nonMemberGroup.setAdjustDate(new Date());
			nonMemberGroup.setIsAdjustment(true);
			Set<NonMemberRegister> nmrSet = nonMemberGroup.getSignUps();

			signUp = save(signUp);
			NonMemberRegister nonMemberRegister = new NonMemberRegister();
			nonMemberRegister.setNonMemberGroup(nonMemberGroup);
			nonMemberRegister.setSignUpRegister(signUp);
			nonMemberRegister.setVersion(0);
			nonMemberRegister = nonMemRegisterManager.save(nonMemberRegister);
			nmrSet.add(nonMemberRegister);

			nonMemberGroup.setSignUps(nmrSet);
			nonMemberGroup = nonMemberGroupManager.save(nonMemberGroup);
			map.put("NonMember", nonMemberGroup);
		} else {
			PlanItemGroup planItemGroup = planItemGroupManager.get(pkGroup);
			planItemGroup.setAdjustDate(new Date());
			planItemGroup.setIsAdjustment(true);

			Set<SignUpRegister> surSet = planItemGroup.getSignUps();
			signUp.setPlanItemGroup(planItemGroup);
			signUp = save(signUp);
			surSet.add(signUp);

			planItemGroup.setSignUps(surSet);
			planItemGroup = planItemGroupManager.save(planItemGroup);

			map.put("GroupReserve", planItemGroup);

			// 推送一条收费单
			SignUpCharge signUpCharge = new SignUpCharge();
			signUpCharge.setSignUpRegister(signUp);
			signUpCharge.setVersion(0);
			signUpCharge = signUpChargeManager.save(signUpCharge);
		}
		return map;
	}

}
